package com.zjitc.result;


import lombok.Data;

/**
 * @Author:徐莹
 * @Date:2025/04/21 15:57:31
 */

@Data
public class  R<T>{
    private Integer code;
    private String message;
    private T data;

    public static <T> R<T> ok(T data) {
        R<T> r = new R<T>();
        r.setCode(200);
        r.setMessage("操作成功");
        r.setData(data);
        return r;
    }
    public static <T> R<T> ok(T data, String message) {
        R<T> r = new R<T>();
        r.setCode(200);
        r.setMessage("操作成功");
        r.setData(data);
        return r;
    }
    public static <T> R<T> error(String message) {
        R<T> r = new R<T>();
        r.setCode(500);
        r.setMessage("操作失败");
        return r;

    }
    public static <T> R<T> error(T data, String message) {
        R<T> r = new R<T>();
        r.setCode(500);
        r.setMessage("操作失败");
        r.setData(data);
        return r;

    }

}
